package com.gzsxy.esjy.service.product.controller;

import com.gzsxy.esjy.service.base.dto.response.DefaultResponse;
import com.gzsxy.esjy.service.base.dto.response.ProductPicRsp;
import com.gzsxy.esjy.service.product.entity.ProductPic;
import com.gzsxy.esjy.service.product.service.ProductPicService;
import com.gzsxy.esjy.service.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xiaolong
 * @version 1.0
 * @description: 商品图片
 * @date 2022/1/23 11:51
 */
@CrossOrigin  //解决跨域
@RefreshScope    //动态刷新配置文件-外部配置文件
@RestController
@RequestMapping("/admin/productPic")
@Api("商品图片管理")
public class ProductPicController {

    @Autowired
    private ProductPicService productPicService;


    @GetMapping("/{productId}")
    @ApiOperation("根据商品id查询对应的图片")
    public DefaultResponse getPicByProductId(@ApiParam(value = "商品id",required = false,defaultValue ="1" ) @PathVariable String productId){
        List<ProductPicRsp> rspList =  productPicService.getPicByProductId(productId);
        return DefaultResponse.ok(rspList);
    }
}
